package com.mallcai.bigdata.ladon.dpl.mapper.report.provider;

import com.mallcai.bigdata.ladon.dpl.entity.report.QueryField;
import com.mallcai.bigdata.ladon.dpl.mapper.BaseSqlProvider;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.SQL;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
public class QueryFieldSqlProvider extends BaseSqlProvider<QueryField> {

    public static final String TB_QUERY_FIELD = "r_query_field";

    /**
     * 获取表名
     *
     * @return String
     */
    @Override
    public String getTableName() {
        return TB_QUERY_FIELD;
    }

    /**
     * 获取插入数据的字段列表
     *
     * @return Map
     */
    @Override
    public Map<String, String> getInsertColumns() {
        Map<String, String> map = new LinkedHashMap<>();
        map.put("report_id", "#{reportId}");
        map.put("show_name", "#{showName}");
        map.put("query_name", "#{queryName}");
        map.put("data_type", "#{dataType}");
        map.put("val_default", "#{valDefault}");
        map.put("val_max", "#{valMax}");
        map.put("val_min", "#{valMin}");
        map.put("val_forbidden", "#{valForbidden}");
        map.put("must_fill_in", "#{mustFillIn}");
        map.put("order_by_type", "#{orderByType}");
        map.put("placeholder", "#{placeholder}");
        map.put("err_message", "#{errMessage}");
        map.put("depend_on", "#{dependOn}");
        map.put("type", "#{type}");
        map.put("lov_report_id", "#{lovReportId}");
        map.put("sort_id", "#{sortId}");
        return map;
    }

    /**
     * 获取更新操作的字段列表
     *
     * @return Map
     */
    @Override
    public Map<String, String> getUpdateColumns() {
        Map<String, String> map = new LinkedHashMap<>();
        map.put("reportId", "report_id");
        map.put("showName", "show_name");
        map.put("queryName", "query_name");
        map.put("dataType", "data_type");
        map.put("valDefault", "val_default");
        map.put("valMax", "val_max");
        map.put("valMin", "val_min");
        map.put("valForbidden", "val_forbidden");
        map.put("mustFillIn", "must_fill_in");
        map.put("orderByType", "order_by_type");
        map.put("placeholder", "placeholder");
        map.put("errMessage", "err_message");
        map.put("dependOn", "depend_on");
        map.put("type", "type");
        map.put("lovReportId", "lov_report_id");
        map.put("sortId", "sort_id");
        return map;
    }
}
